package com.ego.controller;

import com.ego.commons.pojo.EasyUIDatagrid;
import com.ego.commons.pojo.EgoResult;
import com.ego.pojo.TbContent;
import com.ego.service.TBContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TBContentController {


    @Autowired
    private TBContentService tbContentService;

    @PostMapping("/content/save")
    public EgoResult save(TbContent tbContent){
        return tbContentService.insert(tbContent);
    }
    @GetMapping("/content/query/list")
    public EasyUIDatagrid list(long categoryId, int page, int rows){
        return tbContentService.selectTbContentPageByCategoryId(categoryId,page,rows);
    }

    @PostMapping("/rest/content/edit")
    public EgoResult update(TbContent tbContent){
        return tbContentService.update(tbContent);
    }

    @PostMapping("/content/delete")
    public EgoResult delete(@RequestParam List<Long> ids){
        return tbContentService.deleteByIds(ids);
    }
}
